package org.dromara.common.translation.core.impl;

import lombok.AllArgsConstructor;
import org.dromara.common.core.service.OssService;
import org.dromara.common.translation.annotation.Translation;
import org.dromara.common.translation.annotation.TranslationType;
import org.dromara.common.translation.constant.TransConstant;

// SAIL url转oss_id
@AllArgsConstructor
@TranslationType(type = TransConstant.OSS_URL_TO_ID)
public class OssIdTranslationImpl extends SimpleTranslationImpl {
    private final OssService ossService;

    @Override
    public Object translation(Object key, Translation translation) {
        if (key instanceof String ids) {
            return ossService.selectIdByUrls(ids);
        } else if (key instanceof Long id) {
            return ossService.selectIdByUrls(id.toString());
        }
        return null;
    }
}
